<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'pessoa.label', default: 'Pessoa')}" />
        <title><g:message code="default.list.label" args="[entityName]" /></title>
    </head>
    <body>
        <div class="cabelistlateral"><img src="${resource(dir:'images',file:'seta_cabecalho_20x20.png')}" /> Lista de Usuário</div><br/>
        <div class="body">
            <g:form action="list" >
              <tr class="prop">
                    <td valign="top" class="name">
                        <label for="id">Código: </label>
                    </td>
                    <td valign="top">
                        <g:textField name="id" maxlength="30" size="10" value="" />
                    </td>
                </tr>  
              <tr class="prop">
                    <td valign="top" class="name">
                        <label for="nome">Nome: </label>
                    </td>
                    <td valign="top">
                        <g:textField name="nome" maxlength="100" size="50" value="" />
                    </td>
                </tr>
                <tr>
                  <td class="btlistarcadastro">
                    <g:submitButton name="buscar" class="save ui-corner-all" value="BUSCAR" />                                  
                  </td>
                </tr>  
            </g:form>
          </br>
            <g:if test="${flash.message}">
              <div class="message ui-corner-all">${flash.message}</div>
            </g:if>
            <div class="nav">
                <span class="menuButton"><g:link class="create" action="create">Novo Usuário</g:link></span>
            </div>
            <div class="list">
                <table>
                    <thead>
                        <tr>
                            <g:sortableColumn property="id" title="${message(code: 'pessoa.id.label', default: 'Código')}" />
                            <g:sortableColumn property="nome" title="${message(code: 'pessoa.nome.label', default: 'Nome')}" />
                            <g:sortableColumn property="status" title="${message(code: 'pessoa.status.label', default: 'Status')}" />
                            <g:sortableColumn property="username" title="${message(code: 'pessoa.username.label', default: 'User')}" />
                            <td colspan="2" class="acao">Ações</td>
                        </tr>
                    </thead>
                    <tbody>
                    <g:each in="${pessoaInstanceList}" status="i" var="pessoaInstance">
                        <%
                        String st = "";
                        style     = "";
                        if(pessoaInstance.status == "1"){
                          st = "Ativo";
                          style     = " style='color:#006600; font-weight:bold;'";
                        }else{
                          st = "Inativo";
                          style     = " style='color:#ff0000; font-weight:bold;'";
                        }
                        %>
                        <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                            <td>${fieldValue(bean: pessoaInstance, field: "id")}</td>
                            <td>${fieldValue(bean: pessoaInstance, field: "nome")}</td>
                            <td<%=style%>><%=st%></td>
                            <td>${fieldValue(bean: pessoaInstance, field: "username")}</td>
                            <td class="ico">
                              <g:link action="edit" id="${pessoaInstance.id}">
                                <img src="${resource(dir:'images',file:'ico_edit.png')}" alt="Editar Item" title="Editar Item" />
                              </g:link>
                            </td>
                            <td class="ico">
                                <a href="${createLink(uri: '/pessoa/delete/'+pessoaInstance.id)}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Confirma aexclusão do registro?')}');">
                                    <img src="${resource(dir:'images',file:'ico_delete.png')}" alt="Excluir Item" title="Excluir Item" class="formacao" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}"  />
                                </a>
                            </td>                              
                        </tr>
                    </g:each>
                    </tbody>
                </table>
            </div>
            <div class="paginateButtons">
                <g:paginate total="${pessoaInstanceTotal}" />
            </div>
        </div>
    </body>
</html>
